package com.am.mosl.cityandroid;

import android.app.Application;
import android.content.Context;

import com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator;
import com.nostra13.universalimageloader.cache.memory.impl.UsingFreqLimitedMemoryCache;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
import com.nostra13.universalimageloader.core.assist.QueueProcessingType;


/**
 * @author 邓思宇 登录用的主类
 * 
 */
public final class CityApp extends Application {

	private static CityApp globalContext = null;
	private static String phoneNumber;
	private static String Token;



    public CityApp(){

    }


    public CityApp(Context context){
        super();
    }

    @Override
    public void onCreate() {

        super.onCreate();
        initImageLoader();
    }

	public static CityApp getGlobalContext() {
		return globalContext;


	}

	public static void setGlobalContext(CityApp globalContext) {
		CityApp.globalContext = globalContext;
	}

	public static String getPhoneNumber() {
		return phoneNumber;
	}

	public static void setPhoneNumber(String phoneNumber) {
		CityApp.phoneNumber = phoneNumber;
	}

	public static String getToken() {
		return Token;
	}

	public static void setToken(String token) {
		Token = token;
	}


    private void initImageLoader() {

        ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(
                this)
                .memoryCacheExtraOptions(480, 800)
                .threadPoolSize(3)
                .threadPriority(Thread.NORM_PRIORITY - 2)
                .denyCacheImageMultipleSizesInMemory()
                .memoryCache(new UsingFreqLimitedMemoryCache(2 * 1024 * 1024))
                .memoryCacheSize(2 * 1024 * 1024)
                .discCacheSize(50 * 1024 * 1024)
                .discCacheFileNameGenerator(new Md5FileNameGenerator())
                .tasksProcessingOrder(QueueProcessingType.LIFO)
                .discCacheFileCount(100)
                .defaultDisplayImageOptions(DisplayImageOptions.createSimple())
                .build();// 开始构建
        ImageLoader.getInstance().init(config);
    }

}
